package com.zj.viewpagerdemo.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zj.viewpagerdemo.R;
import com.zj.viewpagerdemo.fragment.MainFragment;

/**
 * Created by Lenovo on 2017/4/25.
 */

public class Main2Adapter extends FragmentPagerAdapter {

    private Context context;

    public static String[] Tabs;

    public Main2Adapter(Context context, FragmentManager fm) {
        super(fm);

        this.context = context;
        Tabs = context.getResources().getStringArray(R.array.arrays);
    }

    @Override
    public Fragment getItem(int position) {
        return MainFragment.newInstance(Tabs[position]);
    }

    @Override
    public int getCount() {
        return Tabs.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
//        return super.getPageTitle(position);
        return Tabs[position];
    }
}
